function data = dataForSMM(params,calibrateParams,orderApp,T,selectY,setupModel,setupEPer,appMethod)

% Adding the calibrated values to params
selectParams = fieldnames(params);
namesCalibrate = setdiff(fieldnames(calibrateParams),selectParams);
for i=1:size(namesCalibrate,1)
   name = namesCalibrate(i);  
   params.(name{1}) = calibrateParams.(name{1}); 
end

[model,errorMes] = perturbationDSGEmodel(params,orderApp,setupModel);
% Generating N.i.d. shocks to the economy
rng(1,'twister'); 
shocks = randn(model.ne,T); %Simulating from a random normal
if appMethod == 1
    x0=model.h0;    % initial state is set at the steady state
    pruning=0;      % no pruning
    ySim=simul(x0,shocks,model.g0,model.h0,model.eta,model.derivs,orderApp,pruning);
elseif appMethod == 2
    setupEPer = infoToSetupEPer(model,setupEPer);    
    ySim = simExtendedPer(model,shocks,setupEPer);
end
ySim = untransformYandX(ySim,model);
data = ySim(selectY,:)';

end

